package com.x.erp.service;

import java.util.List;

import com.x.erp.model.CarLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.alibaba.dubbo.config.annotation.Service;
import com.x.erp.dao.CarSaleDao;
import com.x.erp.manage.CarSaleManage;
import com.x.erp.model.CarSale;
import com.x.erp.rpc.CarSaleRpcService;
import com.x.framework.exception.BusinessException;
import com.x.framework.exception.ExceptionCode;
import com.x.framework.service.BaseService;

/**
 * 销售出库服务
 */
@Component
@Service(interfaceName = "com.x.erp.rpc.CarSaleRpcService", timeout = 60000)
public class CarSaleService extends BaseService implements CarSaleRpcService {

	@Autowired
	private CarSaleDao carSaleDao;//销售出库信息DAO

	@Autowired
	private CarSaleManage carSaleManage;//销售出库信息Manage

	/**
	 * 查询销售出库列表
	 * @param carSale
	 * @return
	 */
	@Override
	public List<CarSale> selectCarSaleList(CarSale carSale){
		try {
			return carSaleDao.selectCarSaleList(carSale);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

	/**
	 * 查询销售出库数量
	 * @param carSale
	 * @return
	 */
	@Override
	public int selectCarSaleNum(CarSale carSale){
		try {
			return carSaleDao.selectCarSaleNum(carSale);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

	/**
	 * 新增销售出库信息
	 * @param carSale
	 * @return
	 */
	@Override
	public CarSale insertCarSale(CarSale carSale, CarLog carLog){
		try {
			return carSaleManage.insertCarSale(carSale, carLog);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

	/**
	 * 修改销售出库信息
	 * @param carSale
	 * @return
	 */
	@Override
	public int updateCarSale(CarSale carSale){
		return this.update(carSale);
	}

}
